package org.web.clientlistmanager.server.runner;

import io.netty.channel.ChannelFuture;
import lombok.Getter;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import io.netty.bootstrap.ServerBootstrap;

@Component
@Getter
public class NettyServerRunner implements CommandLineRunner {

    private final ServerBootstrap serverBootstrap;

    public NettyServerRunner(ServerBootstrap serverBootstrap) {
        this.serverBootstrap = serverBootstrap;
    }

    @Override
    public void run(String... args) {
        try {
            ChannelFuture channelFuture = serverBootstrap.bind(8085).sync().channel().closeFuture().sync();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
}
